import Mock from 'mockjs'

const mock1 = Mock.mock({
    'name|1-10': 'test',
    'name2|5': 'softwaredev1',
    'number1|+1': 1
})

const mock2 = Mock.mock({
    'number1|1-100.1-10': 1,
    'number2|123.1-10': 1,
    'number3|123.3': 1,
    'number4|123.10': 1.123,
    'bool1|2-3': false,
    func: () => {}
})

const mock3 = Mock.mock(
    Mock.mock({
        name: {
            firstname: '@FIRST',
            middlename: '@FIRST',
            lastname: '@LAST',
            full: '@firstname @middlename @lastname'
        }
    })
)

const users = Mock.mock({
    'users|10': [
        {
            email: '@email',
            username: '@name',
            password: '@word',
            userid: '@guid'
        }
    ]
})

Mock.mock('/api/users', 'get', users)

Mock.Random.extend({
    live: function () {
        const dormList = ['一善书院', '双馨书院', '三创书院', '四实书院', '八方书院', '拾德书院']
        return this.pick(dormList)
    }
})

const students = Mock.mock({
    'students|10': [
        {
            id: '@id',
            name: '@cname',
            live: '@live',
            'score|1-100': 1
        }
    ]
})

Mock.mock('/api/students', 'get', (options) => {
    console.log(options.url)
    return students
})

Mock.mock('/api/login', 'post', (options) => {
    console.log(options)
    //....

    return {
        token: 'TESTTOKEN'
    }
})

Mock.setup({ timeout: 200 - 3000 })
